import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AgentVO, AgentForm, AgentQuery } from '@/api/credit/agent/types';

/**
 * 查询代理列表
 * @param query
 * @returns {*}
 */

export const listAgent = (query?: AgentQuery): AxiosPromise<AgentVO[]> => {
  return request({
    url: '/credit/agent/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询代理详细
 * @param id
 */
export const getAgent = (id: string | number): AxiosPromise<AgentVO> => {
  return request({
    url: '/credit/agent/' + id,
    method: 'get'
  });
};

/**
 * 新增代理
 * @param data
 */
export const addAgent = (data: AgentForm) => {
  return request({
    url: '/credit/agent',
    method: 'post',
    data: data
  });
};

/**
 * 修改代理
 * @param data
 */
export const updateAgent = (data: AgentForm) => {
  return request({
    url: '/credit/agent',
    method: 'put',
    data: data
  });
};

/**
 * 删除代理
 * @param id
 */
export const delAgent = (id: string | number | Array<string | number>) => {
  return request({
    url: '/credit/agent/' + id,
    method: 'delete'
  });
};
